var app = getApp();
Page({
    data:{
        siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
        page : {
            isend : false,
            doing : false,
            doo : 'fenxiao',
            pdata : {
                op : 'orderrecord',
                page : 1,
                type : 0,
                status:0
            },
            waitf : 0,
            nodataf : 0,
        },
        datalist : [],
        params : {color : '#ffffff'},
        orderinfo : {},
    },
    onLoad:function(options){
        var self = this;
        var zfid = options.zfid ? options.zfid : '';
        self.setData({
            options : options,
        });
        app.com.auth(function(user){
            app.com.getPage(self,self.data.page,20,function(res){
                var data = res.data.data;
                self.setData({
                   datalist : data.list,
                   params : data.params,
                   Pagetheme : res.data.data.params.style,
                },function(){
                    self.setData({
                        inited : true,
                    });
                });

            },false,function(res){
                app.com.alert(res.data.message);
            });
        });

        wx.setNavigationBarTitle({
          title:  '订单推广记录',
        });
       
    },
    onChange(e){
        var self = this;
        if( self.data.ising || ( e.detail.name*1 == self.data.page.pdata.status ) ) return false;
        self.data.ising = true;

        self.setData({
            datalist : [],
            'page.pdata.status' : e.detail.name*1,
            'page.pdata.page' : 1,
            'page.isend' : false,
            'page.waitf' : 0,
            'page.nodataf' : 0
        });
        app.com.getPage(self,self.data.page,20,function(res){
            self.setData({
                datalist : res.data.data.list,
            });
        });
        self.data.ising = false;
    },
    onReachBottom : function(){
        var self = this;
        app.com.getPage(self,self.data.page,20,function(res){
            self.setData({
                datalist : self.data.datalist.concat(res.data.data.list)
            });
        });
    },
    scanoinfo(e){
        var self = this;
        var postdata = {
            op : 'orderinfo',
            oid : e.currentTarget.dataset.oid,
        }
        app.com.http('fenxiao','POST',postdata,0,true,'','',function(res){
            if (res.data && !res.data.errno) {
                self.setData({
                    orderinfo : res.data.data.info,
                    isshowinfo : true,
                });
            }else{
                app.com.alert(res.data.message);
            }
        })
    },
    onCloseinfo(){
        this.setData({
            isshowinfo : false,
        })
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    toweburl : function(e){
        app.com.toweburl( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },

})